<cfcomponent extends="Wheels">
	<!--- Init() function that gets called every page load in the framework --->
	<cffunction name="init">
		<cfargument name="Action" default="#REQUEST.wheels.params.action#">
		<cfscript>
			if(StructKeyExists(SESSION, "User") AND ARGUMENTS.Action IS "login") {
				StructDelete(SESSION, 'User');		
			} else if(ARGUMENTS.Action IS "") {
				Set(Navigation = { tab = "login", tabNames = ["Login"] }); 
			} else {	
				Set(Navigation = { tab = ARGUMENTS.Action, tabNames = [Titleize(ARGUMENTS.Action)] }); 
			}

			Filters(through="verifyLogin", except="login,signin");
		</cfscript>
	</cffunction>
	
	<!--- Verifies existance of User's session, if doesn't exist redirects to Login page --->
	<cffunction name="verifyLogin">
		<cfscript>
			if(NOT StructKeyExists(SESSION, "User")) {
				Set(Navigation = {	tab = "login", tabNames = ["Login"]	});
				RedirectTo(controller="Main", action="login");
			}
		</cfscript>
	</cffunction>
</cfcomponent>